<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>发起任务</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function(){
			top.$.jBox.tip.mess = null;
			layui.use(['laypage', 'form', 'table'], function(){
				form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
				form.render();
				var laypage = layui.laypage;
				laypage.render({elem:'pageDiv',
					count: ${page.count}, //数据总数，从服务端得到
					curr:${page.pageNo},
					limit:30,
					layout: ['prev', 'page', 'next', 'count'],
					jump: function(obj, first){
					//obj包含了当前分页的所有参数，比如：
					 // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
					 // console.log(obj.limit); //得到每页显示的条数
					
					//首次不执行
						if(!first){
							$("#firstPage").val(false);
							page(obj.curr,obj.limit);
						}
					}
				});
				var table = layui.table;
				table.init('processTable',{limit:30});
			}); 
		});
		function page(n,s){
        	location = '${ctx}/act/task/process/?pageNo='+n+'&pageSize='+s;
        }
	</script>
</head>
<body>
	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		<ul class="layui-tab-title">
			<li><a href="${ctx}/act/task/todo/">待办任务</a></li>
			<li><a href="${ctx}/act/task/historic/">已办任务</a></li>
			<li class="layui-this"><a href="${ctx}/act/task/process/">新建任务</a></li>
		</ul>
	</div>
	<blockquote class="layui-elem-quote quoteBox">
	<form id="searchForm" action="${ctx}/act/task/process/" method="post"class="layui-form">
		<div class="layui-inline">
		<select id="category" name="category" class="layui-input">
			<option value="">全部分类</option>
			<c:forEach items="${fns:getDictList('act_category')}" var="dict">
				<option value="${dict.value}" ${dict.value==category?'selected':''}>${dict.label}</option>
			</c:forEach>
		</select>
		</div>
		&nbsp;<input id="btnSubmit" class="layui-btn search_btn" type="submit" value="查询"/>
	</form>
	</blockquote>
	<sys:message content="${message}"/>
	<table class="layui-table" lay-filter="processTable">
		<thead>
			<tr>
				<th lay-data="{field:'type', minWidth:100}">流程分类</th>
				<th lay-data="{field:'label', minWidth:100}">流程标识</th>
				<th lay-data="{field:'name', minWidth:100}">流程名称</th>
				<th lay-data="{field:'image', minWidth:150}">流程图</th>
				<th lay-data="{field:'version', minWidth:90}">流程版本</th>
				<th lay-data="{field:'updataTime', minWidth:150}">更新时间</th>
				<th lay-data="{field:'todoFlag', minWidth:90, fixed:'right'}">操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="object">
				<c:set var="process" value="${object[0]}" />
				<c:set var="deployment" value="${object[1]}" />
				<tr>
					<td>${fns:getDictLabel(process.category,'act_category','无分类')}</td>
					<td><a class="layui-blue" href="${ctx}/act/task/form?procDefId=${process.id}">${process.key}</a></td>
					<td>${process.name}</td>
					<td><a class="layui-blue" target="_blank" href="${pageContext.request.contextPath}/act/diagram-viewer?processDefinitionId=${process.id}">${process.diagramResourceName}</a><%--
						<a target="_blank" href="${ctx}/act/process/resource/read?procDefId=${process.id}&resType=image">${process.diagramResourceName}</a>--%></td>
					<td><b title='流程版本号'>V: ${process.version}</b></td>
					<td><fmt:formatDate value="${deployment.deploymentTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<td>
						<a class="layui-btn layui-btn-normal layui-btn-xs" href="${ctx}/act/task/form?procDefId=${process.id}">启动流程</a>
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div id="pageDiv" class="pagination layui-elem-field layui-field-title">${page}</div>
</body>
</html>
